import Vue from 'vue'

// 导入ElementUI
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

import App from './App.vue'
import router from './router'
import store from './store'
import importDirective from './directive'
import axios from 'axios'
import VueContextMenu from '@xunlei/vue-context-menu'
import VueCookies from 'vue-cookies'
import VueAxios from 'vue-axios'

// import http from './utils/http' // 引入请求工具

Vue.use(VueContextMenu)

Vue.use(ElementUI)
Vue.use(importDirective)
Vue.config.productionTip = false
Vue.use(VueAxios, axios)
Vue.use(VueCookies)
// require('./mock')
Object.defineProperty(Vue.prototype, '$axios', { value: axios })

Vue.prototype.post = function (url, dist, methodSucc) {
  Vue.axios.post(url, dist, {
    headers: {
      'X-CSRFToken': this.$cookies.get('csrftoken'),
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
    .then((response) => {
      methodSucc(response)
    })
    .catch((error) => {
      console.log(error)
      this.$message.error('请求错误')
    })
}
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
